//
//  GuideViewController.m
//  Peso Guide
//
//  Created by macbook on 2025/6/5.
//

#import "GuideViewController.h"
#import "LoginViewController.h"
#import "ViewController.h"

@interface GuideViewController ()

@property (nonatomic, strong) UIScrollView *scrollView;

@end

@implementation GuideViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    _scrollView = [PesoKit createScrollViewWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight) backGroundColor:ColorHex(@"#FFFFFF")];
    _scrollView.contentSize = CGSizeMake(KScreenWidth*3, KScreenHeight);
    _scrollView.pagingEnabled = YES;
    _scrollView.scrollEnabled = NO;
    _scrollView.showsVerticalScrollIndicator = NO;
    _scrollView.showsHorizontalScrollIndicator = NO;
    [self.view addSubview:_scrollView];
    
    for (int i = 0; i < 3; i++) {
        UIImageView *image = [PesoKit createImageViewWithFrame:CGRectMake(KScreenWidth*i, 0, KScreenWidth, KScreenHeight) imageNamed:[NSString stringWithFormat:@"guide%d",i+1]];
        image.userInteractionEnabled = YES;
        [_scrollView addSubview:image];
        
        UIButton *nextButton = [PesoKit createButtonWithFrame:CGRectMake(0, KScreenHeight/2.0, KScreenWidth, KScreenHeight/2.0) backGroundColor:[UIColor clearColor] title:@"" titleColor:ColorHex(@"#FFFFFF") font:FONT(FontWeightStyleRegular, 13)];
        nextButton.tag = 9000+i;
        [nextButton addTarget:self action:@selector(guideClick:) forControlEvents:UIControlEventTouchUpInside];
        [image addSubview:nextButton];
    }
}

- (void)guideClick:(UIButton *)sender {
    DLog(@"111");
    if (sender.tag-9000 == 2) {
        [[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"user_is_first"];
        [[NSUserDefaults standardUserDefaults] synchronize];
        
        [AppStarPre toMain];
        
    }else {
        [_scrollView setContentOffset:CGPointMake(KScreenWidth*(sender.tag-8999), 0) animated:YES];
    }
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
